<template>
  <div style="width: 100%">
    <div class="text-center">
      <el-avatar
        :size="80"
        :src="'http://127.0.0.1:8090/public/avator/' + userInfo.avator"
      />
    </div>

    <ul class="list-group list-group-striped">
      <li class="list-group-item">
        <Icon icon="ep:user" class="mr-5px" />用户名
        <div class="pull-right">{{ userInfo.username }}</div>
      </li>
      <li class="list-group-item">
        <Icon icon="ep:user" class="mr-5px" />手机号码
        <div class="pull-right">{{ userInfo.phone }}</div>
      </li>
      <li class="list-group-item">
        <Icon icon="ep:user" class="mr-5px" />邮箱
        <div class="pull-right">{{ userInfo.email }}</div>
      </li>
      <li class="list-group-item">
        <Icon icon="ep:user" class="mr-5px" />角色
        <div class="pull-right">管理员</div>
      </li>
      <li class="list-group-item">
        <Icon icon="ep:user" class="mr-5px" />性别
        <div class="pull-right">{{ userInfo.sex }}</div>
      </li>
      <li class="list-group-item">
        <Icon icon="ep:user" class="mr-5px" />创建日期
        <div class="pull-right">{{ toTime(userInfo.createTime) }}</div>
      </li>
    </ul>
  </div>
</template>

<script lang="ts" setup>
import { onMounted, ref } from "vue";
import { toTime } from "../../util/toTime";
import { getProUser } from "../../api/userCenter/index";
const userInfo = ref<any>({});
const onLoad = async () => {
  let id = sessionStorage.getItem("id");
  const res = await getProUser(Number(id));
  userInfo.value = res.data.data[0];
  console.log(userInfo.value);
};

onMounted(async () => {
  await onLoad();
});
</script>

<style lang="scss" scoped>
.text-center {
  text-align: center;
  height: 160px;
}
.list-group-striped > .list-group-item {
  border-left: 0;
  border-right: 0;
  border-radius: 0;
  padding-left: 0;
  padding-right: 0;
}

.list-group {
  list-style: none;
  padding-left: 0px;
}
.list-group-item {
  border-bottom: 1px solid #e7eaec;
  border-top: 1px solid #e7eaec;
  margin-bottom: -1px;
  padding: 11px 0px;
  font-size: 13px;
}
.pull-right {
  float: right !important;
}
</style>
